package com.example.demo.demos.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/kafka")
public class kafkaProducer {
    @Autowired
    private KafkaTemplate<String,Object> kafkaTemplate;
//    http://localhost:8082/kafka/sendMessage/qweqwe
    @GetMapping("/sendMessage/{message}")
    public void sendNormalMessage(@PathVariable("message") String message){
        System.out.println(message);
        System.out.println(kafkaTemplate);
        kafkaTemplate.send("topicname",message);
    }

}
